//
//  ST_PairsCenterSectionFooterView.swift
//  btvideo
//
//  Created by mac on 2020/1/10.
//  Copyright © 2020 JarvanZhang. All rights reserved.
//

import UIKit
import SwifterSwift

class ST_PairsCenterSectionFooterView: UITableViewHeaderFooterView {
    
    override init(reuseIdentifier: String?) {
        super.init(reuseIdentifier: reuseIdentifier)
        
        self.contentView.backgroundColor = Color.init(hex: 0xACB4C0)
//        self.contentView.backgroundColor = Color.random
        contentView.clipsToBounds = true
        contentView.addSubview(root_view)
        root_view.snp.makeConstraints { (make) in
            make.edges.equalToSuperview().inset(UIEdgeInsets.init(top: -30, left: 0, bottom: 0, right: 0))
        }
        
        contentView.addSubview(more_data_btn)
        more_data_btn.snp.makeConstraints { (make) in
            make.width.equalTo(140)
            make.height.equalTo(35)
            make.bottom.equalToSuperview().offset(-25)
            make.centerX.equalToSuperview()
        }
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    lazy var root_view:UIView = {
        let control = UIView()
        control.backgroundColor = .white
        control.cornerRadius = 30
        return control
    }()
    

    lazy var more_data_btn:UIButton = {
            
        let control = UIButton.init(type: UIButton.ButtonType.custom)
        control.backgroundColor = Color.init(hexString: "#F2F4F7")
        control.cornerRadius = 35/2.0
        control.setTitleForAllStates(" ")
        control.setTitleColorForAllStates(UIColor.init(hexString: "#333333")!)
        control.titleLabel?.font = UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.semibold)
        control.addTarget(self, action: #selector(more_data_handle), for: UIControl.Event.touchUpInside)
        control.isHidden = true
        return control
    }()

    
    @objc func more_data_handle(){
        
        let vc = ST_LikedPeculiarityViewController()
        
        vc.ta = self.model.ta
        
        vc.accid = self.model.accid
        
        self.parentViewController?.navigationController?.pushViewController(vc)
        
    }
    
    var model = ST_PairsUserCenterSectionModel(){
        didSet{
            if !model.text.isEmpty{
                more_data_btn.setTitleForAllStates(model.text)
                more_data_btn.isHidden = false
            }else{
                more_data_btn.isHidden = true
            }
        }
    }
}
